// pages/newlogin/newlogin.js
Page({
  data:{},
  onLoad(){
    this.localLogin();
  },
  localLogin(){
    let account = wx.getStorageSync("localaccount")
    let psw = wx.getStorageSync("localpsw")
    if (!account||!psw)return;
    getApp().request({
      url:'login',
      data:{
        mobile:account,
        psw: psw
      },success:function(res) {
        console.log(res);
        if(res.data.flag){
          getApp().globalData.UserData = res.data.data;
          try{
            wx.reLaunch({
              url: '../realtime/realtime'
            })
          }catch(e){
            wx.redirectTo({
              url: '../realtime/realtime',
            })
          }
        }
        else{
          if (account != "" && account != null){
            try {
              wx.reLaunch({
                url: '../login/login?account=' + account
              })
            } catch (e) {
              wx.redirectTo({
                url: '../login/login?account=' + account
              })
            }
          }
        }
      },fail(){
        wx.showModal({
            content: '请求失败',
            showCancel:false,
            success: function(res) {
            }
        })
      },complete(){
      }
    },true)
  },
})